home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / ear / mui23dev.lha / MUI / Developer / Modula / txt / MuiClasses.def next >
Text File  |  1994-06-30  |  13KB  |  356 lines

  1. DEFINITION MODULE MuiClasses;
  2.  
  3. (*************************************************************************
  4. ** Structures and Macros for creating MUI custom classes.
  5. **
  6. ** converted for M2 by Christian 'Kochtopf' Scholz
  7. **
  8. **************************************************************************
  9. **
  10. ** $Id: MuiClasses.def 1.6 1994/06/30 21:03:01 Kochtopf Exp $
  11. **
  12. ** $Log: MuiClasses.def $
  13. # Revision 1.6  1994/06/30  21:03:01  Kochtopf
  14. # changed again SHORTINT to SHORTCARD for madAddLeft, etc.
  15. #
  16. # Revision 1.5  1994/06/30  20:56:40  Kochtopf
  17. # Typ bei madAddLeft, etc. von BYTE in SHORTINT geändert, um
  18. # besser damit rechnen zu können.
  19. #
  20. # Revision 1.4  1994/06/27  22:04:58  Kochtopf
  21. # changed name from MUIClasses to MuiClasses
  22. # added definition of mCustomClass
  23. #
  24. # Revision 1.3  1994/06/23  21:36:53  Kochtopf
  25. # upgraded to MUI 2.1
  26. # added mCustumClass-Definition
  27. #
  28. # Revision 1.2  1994/02/19  12:42:19  Kochtopf
  29. # Neue Prozeduren hinzugefuegt, die in mui.h definiert waren.
  30. # Ausserdem etwas die Reihenfolge geaendert, so dass man jetzt alles
  31. # benutzen koennen sollte.
  32. #
  33. # Revision 1.1  1994/02/02  09:37:18  Kochtopf
  34. # Initial revision
  35. #
  36. **
  37. **************************************************************************)
  38.  
  39. FROM    SYSTEM      IMPORT ADDRESS, WORD, BYTE, LONGSET;
  40. FROM    IntuitionD  IMPORT ObjectPtr, WindowPtr, ScreenPtr, DrawInfoPtr, IBox,
  41.                            IntuiMessagePtr, IClassPtr;
  42. FROM    ExecD       IMPORT LibraryPtr;
  43. FROM    GraphicsD   IMPORT TextFontPtr, RastPortPtr;
  44. FROM    MuiSupport  IMPORT APTR;
  45.  
  46. (*
  47. ** at the beginning some general things used for BOOPSI-Objects
  48. *)
  49.  
  50. (* get a pointer to our instance data *)
  51.  
  52. PROCEDURE InstData(cl : IClassPtr; obj : ObjectPtr) : ADDRESS;
  53.  
  54. (* get the size ... *)
  55.  
  56. PROCEDURE InstSize(cl : IClassPtr) : CARDINAL;
  57.  
  58.  
  59. (*
  60. ** now the things concerning MUI's view of the things
  61. **
  62. ** GENERAL NOTES:
  63. **
  64. ** - Everything described in this defintion file is only valid within
  65. **   MUI classes. You may never use any of these things out of
  66. **   a class, e.g. in a traditional MUI application.
  67. **
  68. ** - Except when otherwise stated, all structures are strictly read only.
  69. *)
  70.  
  71. (* Pointer-Types *)
  72.  
  73. TYPE mGlobalInfoPtr     = POINTER TO mGlobalInfo;
  74.      mMinMaxPtr         = POINTER TO mMinMax;
  75.      mNotifyDataPtr     = POINTER TO mNotifyData;
  76.      mAreaDataPtr       = POINTER TO mAreaData;
  77.      mRenderInfoPtr     = POINTER TO mRenderInfo;
  78.      mConfigurationPtr  = ADDRESS;
  79.      WORDPtr            = POINTER TO WORD;
  80.  
  81.  
  82. (* 
  83. ** Definitions for madFlags 
  84. ** (you will get these flags e.g. with a Draw-Method.)
  85. *)
  86.  
  87. TYPE  MADFlags = (drawObject, (* completely redraw yourself *)
  88.                   drawUpdate, (* only update! *)
  89.                   p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
  90.                   p12, p13, p14, p15, p16, p17, p18, p19, p20, p21,
  91.                   p22, p23, p24, p25, p26, p27, p28, p29, p30, p31
  92.                   (* rest is private, but must be specified to get a LONGSET *)
  93.                  );
  94.  
  95.       MADFlagSet = SET OF MADFlags;
  96.  
  97.  
  98. (* 
  99. ** Type definitions of some important Methods
  100. ** You will need them in your own classes.
  101. *)
  102.  
  103. (* Area *)
  104.  
  105. TYPE    mpAskMinMaxPtr  = POINTER TO mpAskMinMax;
  106.         mpDrawPtr       = POINTER TO mpDraw;
  107.         mpHandleInputPtr= POINTER TO mpHandleInput;
  108.         mpSetUpPtr      = POINTER TO mpSetUp;
  109.  
  110. TYPE    mpAskMinMax     = RECORD
  111.                             id          : LONGINT;
  112.                             MinMaxInfo  : mMinMaxPtr;
  113.                           END;
  114.  
  115.         mpDraw          = RECORD
  116.                             id          : LONGINT;
  117.                             flags       : MADFlagSet;
  118.                           END;
  119.  
  120.         mpHandleInput   = RECORD
  121.                             id          : LONGINT;
  122.                             imsg        : IntuiMessagePtr;
  123.                             muikey      : LONGINT;
  124.                           END;
  125.  
  126.         mpSetUp         = RECORD
  127.                             id          : LONGINT;
  128.                             RenderInfo  : mRenderInfoPtr;
  129.                           END;
  130.  
  131. (* (partial) instance data of notify class *)
  132.  
  133. TYPE mNotifyData = RECORD
  134.         mndGlobalInfo       : mGlobalInfoPtr;
  135.         mndUserData         : LONGINT;
  136.         priv0               : LONGINT;
  137.         priv1               : LONGINT;
  138.         priv2               : LONGINT;
  139.         priv3               : LONGINT;
  140.         priv4               : LONGINT;
  141.     END;
  142.  
  143.  
  144. (* mMinMax structure holds information about minimum, maximum
  145.    and default dimensions of an object. *)
  146.  
  147.      mMinMax = RECORD
  148.                 MinWidth   : CARDINAL;
  149.                 MinHeight  : CARDINAL;
  150.                 MaxWidth   : CARDINAL;
  151.                 MaxHeight  : CARDINAL;
  152.                 DefWidth   : CARDINAL;
  153.                 DefHeight  : CARDINAL;
  154.         END;
  155.  
  156. CONST mMAXMAX = 10000; (* use this if a dimension is not limited. *)
  157.  
  158.  
  159. (* (partial) instance data of area class *)
  160.  
  161. TYPE mAreaData = RECORD
  162.                 madRenderInfo       : mRenderInfoPtr;     (* RenderInfo for this object *)
  163.                 madBackground       : ADDRESS(*mImagePtr*); (* Background Image *)
  164.                 madFont             : TextFontPtr;          (* Font *)
  165.                 madMinMax           : mMinMax;              (* min/max/default sizes *)
  166.                 madBox              : IBox;                 (* position and dimension *)
  167.  
  168.                 madAddLeft          : SHORTCARD;            (* frame & innerspacing left offset *)
  169.                 madAddTop           : SHORTCARD;            (* frame & innerspacing top offset *)
  170.                 madSubWidth         : SHORTCARD;            (* frame & innerspacing add. width *)
  171.                 madSubHeight        : SHORTCARD;            (* frame & innerspacing add. height *)
  172.  
  173.                 madFlags            : MADFlagSet;           (* see definitions above *)
  174.  
  175.                 (* ... private data follows ... *)
  176.         END;
  177.  
  178.  
  179.  
  180. (* Global information about configuration and parent application. *)
  181.  
  182. TYPE mGlobalInfo = RECORD
  183.                         mgiConfiguration            : mConfigurationPtr;
  184.                         mgiApplicationObject        : ObjectPtr;
  185.                         (* ... private data follows ... *)
  186.                      END;
  187.  
  188. (* MUI's draw pens *)
  189.  
  190. CONST MPENSHINE      =0;
  191. CONST MPENHALFSHINE  =1;
  192. CONST MPENBACKGROUND =2;
  193. CONST MPENHALFSHADOW =3;
  194. CONST MPENSHADOW     =4;
  195. CONST MPENTEXT       =5;
  196. CONST MPENFILL       =6;
  197. CONST MPENCOUNT      =7;
  198.  
  199.  
  200. (* Information on display environment *)
  201.  
  202. TYPE mRenderInfo = RECORD
  203.                             mriWindowObject        : ObjectPtr;     (* valid between MUIMSetup/MUIMCleanup *)
  204.  
  205.                             mriScreen              : ScreenPtr;     (* valid between MUIMSetup/MUIMCleanup *)
  206.                             mriDrawInfo            : DrawInfoPtr;   (* valid between MUIMSetup/MUIMCleanup *)
  207.                             mriPens                : WORDPtr;       (* valid between MUIMSetup/MUIMCleanup *)
  208.                             mriWindow              : WindowPtr;     (* valid between MUIMShow/MUIMHide *)
  209.                             mriRastPort            : RastPortPtr;   (* valid between MUIMShow/MUIMHide *)
  210.  
  211.                         (* ... private data follows ... *)
  212.                      END;
  213.     
  214.  
  215. (*
  216. ** some procedures to get some information about our object 
  217. *)
  218.  
  219. PROCEDURE muiNotifyData(obj : APTR) : mNotifyDataPtr;
  220. PROCEDURE muiAreaData(obj : APTR) : mAreaDataPtr;
  221. PROCEDURE muiGlobalInfo(obj : APTR) : mGlobalInfoPtr;
  222. PROCEDURE muiRenderInfo(obj : APTR) : mRenderInfoPtr;
  223.  
  224. (*
  225. ** some more specialized functions to retain information about special
  226. ** object-data like rastport, window, etc.
  227. *)
  228.  
  229. PROCEDURE OBJ_app(obj : APTR) : ObjectPtr;
  230. PROCEDURE OBJ_win(obj : APTR) : ObjectPtr;
  231. PROCEDURE OBJ_dri(obj : APTR) : DrawInfoPtr;
  232. PROCEDURE OBJ_window(obj : APTR) : WindowPtr;
  233. PROCEDURE OBJ_screen(obj : APTR) : ScreenPtr;
  234. PROCEDURE OBJ_rp(obj : APTR) : RastPortPtr;
  235. PROCEDURE OBJ_left(obj : APTR) : INTEGER;
  236. PROCEDURE OBJ_top(obj : APTR) : INTEGER;
  237. PROCEDURE OBJ_width(obj : APTR) : INTEGER;
  238. PROCEDURE OBJ_height(obj : APTR) : INTEGER;
  239. PROCEDURE OBJ_right(obj : APTR) : INTEGER;
  240. PROCEDURE OBJ_bottom(obj : APTR) : INTEGER;
  241. PROCEDURE OBJ_addleft(obj : APTR) : INTEGER;
  242. PROCEDURE OBJ_addtop(obj : APTR) : INTEGER;
  243. PROCEDURE OBJ_subwidth(obj : APTR) : INTEGER;
  244. PROCEDURE OBJ_subheight(obj : APTR) : INTEGER;
  245. PROCEDURE OBJ_mleft(obj : APTR) : INTEGER;
  246. PROCEDURE OBJ_mtop(obj : APTR) : INTEGER;
  247. PROCEDURE OBJ_mwidth(obj : APTR) : INTEGER;
  248. PROCEDURE OBJ_mheight(obj : APTR) : INTEGER;
  249. PROCEDURE OBJ_mright(obj : APTR) : INTEGER;
  250. PROCEDURE OBJ_mbottom(obj : APTR) : INTEGER;
  251. PROCEDURE OBJ_font(obj : APTR) : TextFontPtr;
  252. PROCEDURE OBJ_flags(obj : APTR) : MADFlagSet;
  253.  
  254.    
  255. (* User configurable keyboard events coming with MUIMHandleInput *)
  256.  
  257. CONST MUIKEYRELEASE     = -2; (* not a real key, faked when MUIKEYPRESS is released *)
  258. CONST MUIKEYNONE        = -1;
  259. CONST MUIKEYPRESS       =  0;
  260. CONST MUIKEYTOGGLE      =  1;
  261. CONST MUIKEYUP          =  2;
  262. CONST MUIKEYDOWN        =  3;
  263. CONST MUIKEYPAGEUP      =  4;
  264. CONST MUIKEYPAGEDOWN    =  5;
  265. CONST MUIKEYTOP         =  6;
  266. CONST MUIKEYBOTTOM      =  7;
  267. CONST MUIKEYLEFT        =  8;
  268. CONST MUIKEYRIGHT       =  9;
  269. CONST MUIKEYWORDLEFT    = 10;
  270. CONST MUIKEYWORDRIGHT   = 11;
  271. CONST MUIKEYLINESTART   = 12;
  272. CONST MUIKEYLINEEND     = 13;
  273. CONST MUIKEYGADGETNEXT  = 14;
  274. CONST MUIKEYGADGETPREV  = 15;
  275. CONST MUIKEYGADGETOFF   = 16;
  276. CONST MUIKEYWINDOWCLOSE = 17;
  277. CONST MUIKEYWINDOWNEXT  = 18;
  278. CONST MUIKEYWINDOWPREV  = 19;
  279. CONST MUIKEYHELP        = 20;
  280. CONST MUIKEYCOUNT       = 21; (* private *)
  281.  
  282. (*
  283. ** now something about dispatchers.
  284. ** if you have written your dispatcher make sure it has the format of
  285. ** PROCEDURE Dispatcher(cl : IClassPtr; obj : ADDRESS; msg : ADDRESS) : ADDRESS
  286. ** (like DispatcherDef)
  287. ** Then call in your main routine the procedure MakeDispatcher like this :
  288. ** MakeDispatcher(Dispatcher, MyClass),
  289. ** where MyClass is the initialized IClassPtr of your new class.
  290. ** This function will then set up your dispatcher with a little stub which
  291. ** will restore A4 for your (will mean, your programm will be pure, if you
  292. ** do all right)
  293. *)
  294.  
  295. (* here the definition of a dispatcher! *)
  296.  
  297. TYPE    DispatcherDef = PROCEDURE ( (*class*)   IClassPtr,
  298.                                     (*object*)  ADDRESS,
  299.                                     (*message*) ADDRESS) : ADDRESS;
  300.  
  301.  
  302.  
  303. (* now the procedure MakeDispatcher : *)
  304.  
  305. PROCEDURE MakeDispatcher(entry:DispatcherDef; VAR myclass : IClassPtr);
  306.  
  307.  
  308.  
  309. (* 
  310. ** at last a little procedure to fill in the values in the MinMax-Record.
  311. ** You can call it inside an AskMinMax-Method, because it is ever the same...
  312. *)
  313.  
  314. PROCEDURE FillMinMaxInfo (msg : mpAskMinMaxPtr; MinWidth   : CARDINAL;
  315.                                                 DefWidth   : CARDINAL;
  316.                                                 MaxWidth   : CARDINAL;
  317.                                                 MinHeight  : CARDINAL;
  318.                                                 DefHeight  : CARDINAL;
  319.                                                 MaxHeight  : CARDINAL);
  320.  
  321.  
  322. (*
  323. ** 2 useful procedures for testing if some coordinates are inside your object
  324. ** (converted from the ones in class3.c. So look there how to use... )
  325. *)
  326.  
  327. (* this will test if x is between a and b *)
  328.  
  329. PROCEDURE OBJ_between(a,x,b : INTEGER) : BOOLEAN;
  330.  
  331. (* this will test, if the position (x, y) is inside the Object obj *)
  332.  
  333. PROCEDURE OBJ_isInObject(x, y : INTEGER; obj : ObjectPtr) : BOOLEAN;
  334.  
  335.  
  336.  
  337. (* MUI_CustomClass returned by MUI_CreateCustomClass() *)                                    
  338.  
  339. TYPE
  340.     mCustomClass = RECORD
  341.                     mccUserData         : APTR;         (* use for whatever you want *)
  342.                     mcc_UtilityBase     : LibraryPtr;   (* MUI has opened these libraries *)
  343.                     mcc_DOSBase         : LibraryPtr;   (* for you automatically. You can *)
  344.                     mcc_GfxBase         : LibraryPtr;   (* use them or decide to open     *)
  345.                     mcc_IntuitionBase   : LibraryPtr;   (* your libraries yourself.       *)
  346.                                                                                              
  347.                     mcc_Super           : IClassPtr;    (* pointer to super class   *)
  348.                     mcc_Class           : IClassPtr;    (* pointer to the new class *)
  349.  
  350.                     (* ... private data follows ... *)
  351.  
  352.                   END;
  353.                                                                                              
  354.  
  355. END MuiClasses.
  356.